<?php

	// +----------------------------------------------------------------------
	// | 商城模块公共控制器
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\controller\store;

	use app\common\controller\Base;
	use app\event\store\Cart as CartEvent;
	use think\facade\Cookie;

	class Common extends Base
	{
		/**
		 * 当前被访问的店家
		 * @var \app\model\ucenter\User
		 */
		protected $user;
		// 初始化
		protected function initialize()
		{
			parent::initialize();
			$this->user = $this->request->user;
			if ($this->request->isMobile())
			{
				//$this->redirect('http://store.motonoaji.com/h5');
			}
			if ($this->user)
			{
				if (Cookie::has('add_cart'))
				{
					$event = new CartEvent();
					$data = $event->add(json_decode(Cookie::get('add_cart'),true), $this->user);
					Cookie::delete('add_cart');
				}
			}
			$this->assign('v', time());
			$this->assign('user', $this->user);
			$this->assign('action', $this->request->action());
		}
	}
